package com.example.routeplansystem.entity.bo;

import com.alibaba.excel.annotation.ExcelProperty;
import com.example.routeplansystem.entity.po.NodePojo;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @Author lucong
 * @Date 2022/4/10
 */
@Data
@NoArgsConstructor
public class SolutionExcelBO {

    @ExcelProperty("路线编号")
    private Integer routeNo;
    @ExcelProperty("客户id")
    private Integer customerId;
    @ExcelProperty("客户名称")
    private String customerName;
    @ExcelProperty("客户地址")
    private String customerAddress;
    @ExcelProperty("经纬度")
    private String coordinates;
    @ExcelProperty("顺序")
    private Integer sequence;

    public NodePojo toPojo(int userId) {
        NodePojo nodePojo = new NodePojo();
        nodePojo.setNodeName(customerName);
        nodePojo.setNodeAddress(customerAddress);
        nodePojo.setUserId(userId);
        nodePojo.setClientId(customerId);
        String[] split = coordinates.split(",");
        double lng = Double.parseDouble(split[0]);
        double lat = Double.parseDouble(split[1]);
        nodePojo.setLng(lng);
        nodePojo.setLat(lat);
        return nodePojo;
    }
}
